/*
 * 路由权限拦截
 */
import router from "./router";
// 路由判断登录:根据路由配置文件的参数
router.beforeEach((to, from, next) => {
    if (to.matched.some(record => record.meta.requireAuth)) { //判断该路由是否需要登录权限
        const userInfo = sessionStorage.getItem("userInfo")
        console.log("userInfo------:" + userInfo)
        if (userInfo && userInfo.length != 0) { // 判断当前的userInfo是否存在; 登录存入的userInfo
            if (to.path === '/login') {
                //..
            } else {
                next()
            }
        } else {
            next({
                path: '/login'
            })
        }
    } else {
        next()
    }
})